package com.yituo.mjworld.mvc.entity.web;

import com.yituo.mjworld.core.annotation.Rules;
import com.yituo.mjworld.core.web.core.BaseForm;

import javax.persistence.*;

@Entity
@Table(name = "product_props", schema = "web_mojianworld_server", catalog = "")
public class ProductProps extends BaseForm {
  /**
   * 价格可浮动属性
   */
  public static final int CAN_FLOAT = 1;
  /**
   * 价格不可浮动属性
   */
  public static final int NOT_FLOAT = 0;
  @Rules(fieldName = "记录ID", id = true, min = "0")
  public int id;
  @Rules(fieldName = "产品ID", min = "0")
  public int productId;
  @Rules(fieldName = "模版")
  public String template;
  @Rules(fieldName = "属性类型", min = "0", max = "1")
  public int type;

  @Id
  @Column(name = "id", nullable = false)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  @Basic
  @Column(name = "productId", nullable = false)
  public int getProductId() {
    return productId;
  }

  public void setProductId(int productId) {
    this.productId = productId;
  }

  @Basic
  @Column(name = "template", nullable = false, length = 400)
  public String getTemplate() {
    return template;
  }

  public void setTemplate(String template) {
    this.template = template;
  }

  @Basic
  @Column(name = "type", nullable = false)
  public int getType() {
    return type;
  }

  public void setType(int type) {
    this.type = type;
  }

  @Override
  public int hashCode() {
    int result = id;
    result = 31 * result + productId;
    result = 31 * result + (template != null ? template.hashCode() : 0);
    result = 31 * result + type;
    return result;
  }

  @Override
  public boolean validate() {
    return defaultValidate();
  }
}
